﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WinFormStore.实体库;
using WinFormStore.通信层;


namespace WinFormStore.数据层
{
    public class ScannerComService
    {
       public ScannerComLib ScannerCom = new ScannerComLib();
        [Description("串口连接")]
        public void Connect(ScannerInfo scannerInfo)
        {
            ScannerCom.OpenCom(scannerInfo.PortName, scannerInfo.BaudRate, scannerInfo.Parity, scannerInfo.DataBits, scannerInfo.StopBits);
            ScannerCom.CodeReceived += ScannerCom_CodeReceived;
        }
        [Description("串口断开")]
        public void DisConn()
        {
            ScannerCom.CloseCom();
        }
        public event Action<string> CodeReceived;//自定义事件
        private void ScannerCom_CodeReceived(string code)
        {
            CodeReceived?.Invoke(code);
        }
    }
}
